package day52.basic.controller;

import day52.basic.domain.dto.SmsVerifyDto;
import day52.basic.service.IVerifyCodeService;
import day52.basic.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequestMapping("/verify_code")
public class VerifyCodeController {
    @Autowired
    private IVerifyCodeService verifyCodeService;

    /**
     * 获取图片验证码
     * @param imageCodeKey
     * @return
     */
    @GetMapping("/image/{imageCodeKey}")
    public AjaxResult getImgCode(@PathVariable(value = "imageCodeKey") String imageCodeKey){
        return verifyCodeService.getImgCode(imageCodeKey);
    }

    @PostMapping("/smsCode")
    public AjaxResult getSmsCode(@RequestBody @Valid SmsVerifyDto dto){
        return verifyCodeService.getSmsCode(dto);
    }
}
